<template>
  <div class="myownerSmall">
    <div class="herdertop">
      <img src="../../assets/top.png" alt="" class="topImg" />
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>内容管理</el-breadcrumb-item>
        <el-breadcrumb-item>个人中心（小程序）</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="Title">个人中心（小程序）配置</div>
    <div class="contentBox">
      <div class="leftBox">
        <div class="top1">APP我的页面预览</div>
        <div class="imgBox">
          <img src="./top.png" />
        </div>
        <div
          class="item"
          v-for="(item, index) in fetchAllPositionMaterialListData"
          :key="index"
        >
          <left-content-item :itemData="item"></left-content-item>
        </div>
        <div class="goodsGroup">
          <div class="title">精选推荐</div>
          <div class="goodsContent">
            <div v-for="(item, index) in goodsData[0].goodsList" :key="index">
              <div class="imgBox1">
                <img :src="item.goodsImageUrl" />
              </div>
              <div class="goodsName">{{ item.goodsName }}</div>
              <div class="priceGroup">
                <div class="price1">￥{{ item.goodsMinPrice }}</div>
                <div class="price2">{{ item.goodsMaxPrice }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="rightBox"></div>
    </div>
  </div>
</template>

<script>
import leftContentItem from "./leftContentItem.vue";
export default {
  components: { leftContentItem },
  data() {
    return {
      fetchAllPositionMaterialListData: [],
      goodsData: [
        {
          goodsList: []
        }
      ]
    };
  },
  methods: {
    async fetchAllPositionMaterialList() {
      // 获取左侧菜单列表
      await this.$http({
        url: "/memberadmin/mgr/userCenter/fetchAllPositionMaterialList",
        method: "post",
        headers: {
          "platform-type": "1"
        }
      })
        .then(res => {
          const list = res;
          this.fetchAllPositionMaterialListData = list;
        })
        .catch(err => {
          this.$message.error("左侧菜单获取异常，请稍后重试");
        });
    },
    async fetchHotGoodsGroupPositionId() {
      // 获取精选商品
      await this.$http({
        url: "/cmsadmin/appIndex/backManager/fetchHotGoodsGroupPositionId",
        method: "get",
        headers: {
          "platform-type": "1"
        }
      })
        .then(res => {
          this.goodsData = res;
        })
        .catch(err => {
          this.$message.error("系统繁忙，请稍后重试");
        });
    }
  },
  activated() {
    this.fetchAllPositionMaterialList();
    this.fetchHotGoodsGroupPositionId();
  }
};
</script>

<style lang="scss" scoped>
.herdertop {
  height: 8vh;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
  .topImg {
    margin-right: 20px;
  }
}
.Title {
  padding-left: 20px;
  height: 50px;
  line-height: 50px;
  font-size: 20px;
  font-weight: 900;
}
.contentBox {
  margin: 0 20px;
  border: 10px solid #ebeef1;
  min-height: 100px;
  border-radius: 10px;
  display: flex;
  justify-content: flex-start;
  // align-items: center;
  .leftBox {
    width: 40%;
    .top1 {
      height: 20px;
      background-color: pink;
      font-size: 14px;
      text-align: center;
      margin: 5px;
    }
    .imgBox {
      margin-left: 5px;
      margin-right: 5px;
      img {
        width: 100%;
      }
    }
  }
  .rightBox {
  }
}
</style>
<style lang="scss" scoped>
.goodsGroup {
  transform: translateY(-60px);
  .title {
    padding-left: 20px;
    padding-bottom: 15px;
  }
  .goodsContent {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    padding: 0 20px;
    .imgBox1 {
      width: 160px;
      height: 160px;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .goodsName {
      font-size: 14px;
      font-weight: 500;
      width: 130px;
      text-overflow: ellipsis;
      padding-top: 5px;
      padding-bottom: 10px;
    }
    .priceGroup {
      display: flex;
      .price1 {
        color: #fa541c;
      }
      .price2 {
        line-height: 20px;
        margin-left: 20px;
        font-size: 12px;
        color: #999;
      }
    }
  }
}
</style>
